﻿using System;
using __ts.Core.Api;
using __ts.Core.FilterChain;

/*
 *  author: able
 *  @2012/2/21 10:36:57
 * 
 */
namespace __ts.Core.Filter.Codec
{
    /// <summary>
    /// 
    /// </summary>
    public interface ProtocolEncoder
    {
        /**
         * Encodes higher-level message objects into binary or protocol-specific data.
         * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
         * method with message which is popped from the session write queue, and then
         * the encoder implementation puts encoded messages (typically {@link ByteBuffer}s)
         * into {@link ProtocolEncoderOutput}.
         *
         * @throws Exception if the message violated protocol specification
         */
        Object encode(IoSession session, Object message, WriteFilterChainController controller); // throws Exception;

        /**
         * Releases all resources related with this encoder.
         *
         * @throws Exception if failed to dispose all resources
         */
        void dispose(IoSession session);
    }
}